<?php

class MyMemory {

	protected static $instance;
	protected static $livetime = 5000000;

	public static function getInstance() {
		return self::ensureInitialisation();
	}
	
	public static function set($key, $val) {
		self::ensureInitialisation();
		self::$instance->set($key, $val, self::$livetime);
	}
	
	public static function get($key) {
		self::ensureInitialisation();
		return self::$instance->get('testkey');
	}
	
	protected static function ensureInitialisation () {
		if (empty(self::$instance)) {
			self::$instance = new Memcached(1);
			self::$instance->addServer('127.0.0.1', 11211);
		}
		return self::$instance;
	}
}